package top.timous.mapper;

import org.apache.ibatis.annotations.*;
import top.timous.pojo.UserInfo;

import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select * from users")
    List<UserInfo> queryAll();

    @Select("select * from users where account = #{account} and password = #{password}")
    UserInfo queryUserById(UserInfo userInfo);

    @Insert("INSERT INTO `users`(`account`,`password`,`user_name`) VALUES(#{account},#{password},#{userName})")
    void saveUser(UserInfo userInfo);


    @Update("UPDATE `users` SET `account` = #{account} , `password` = #{password} , `user_name` = #{userName} WHERE `user_id` = #{userId}")
    void updateUser(UserInfo userInfo);

    @Select("SELECT * FROM `users` WHERE account = #{account}")
    UserInfo queryUserByAccount(UserInfo userInfo);

    @Delete("DELETE FROM `users` WHERE `account` = #{account}")
    void deleteUserByAccount(@Param("account") String account);
}
